<template>
  <div id="consultantId">
    <div class="bg-fff pd_t_50 pd_b_45 text-cent">
      <div class="head-portrait"><img :src="list.avatar" /></div>
      <div class="font-28 font-b col-333 pd_t_30">{{list.nickName}}</div>
      <div class="pd_t_30 row cont-center jcenter" style="justify-content: center">
        <u-tag :text="item" type="info" shape="circle" v-for="(item,index) in advisorLabel" :key="index"
               style="margin-left: 5upx;margin-right: 5upx"/>
      </div>
    </div>
    <div class="bg-fff mg_t_10">
      <u-form ref="uForm" label-width="240" label-align="center">
        <u-form-item prop="name" :label="`${title}电话`">
          {{list.phonenumber}}
          <view class="wrap" slot="right">
            <view  @click="call(list.phonenumber)" class="font-24 col-1f476d text-cent btn-style">拨打</view>
          </view>
        </u-form-item>
        <u-form-item prop="name"  :label="`${title}邮箱`">
          {{list.email}}
          <view class="wrap" slot="right">
            <view  @click="copy(list.email)" class="font-24 col-1f476d text-cent btn-style">复制</view>
          </view>
        </u-form-item>
        <u-form-item prop="name"  label="微信号">
          {{list.wxNumber}}
          <view class="wrap" slot="right">
            <view  @click="copy(list.wxNumber)" class="font-24 col-1f476d text-cent btn-style">复制</view>
          </view>
        </u-form-item>
      </u-form>
    </div>
    <div class="bg-fff mg_t_10 pd_t_50" style="padding-bottom: 1.5upx;">
      <div class="font-26 font-666 pd_l_30 pd_r_30 pd_b_30" v-html="list.advisorDetail"></div>
    </div>
    <div class="btn-container pd_t_19 pd_b_20">
      <u-button type="primary" :custom-style="customStyle"
                open-type="contact"
                shape="circle">在线沟通</u-button>
      <u-button type="primary" :custom-style="customStyle1"
                shape="circle" @click="popupShow = true">申请测评报告</u-button>
    </div>
    <u-modal v-model="popupShow" confirm-text="确认" confirm-color="#1f476d"
             @cancel="onClickPopupHide" show-cancel-button
             @confirm="onClickConfirm" :show-title="false">
      <view class="slot-content" style="padding-left: 30upx;padding-right: 30upx">
        <div class="row jcenter" style="justify-content: center;padding-top: 30upx;padding-bottom: 20upx">
          <u-icon name="info-circle-fill" size="100" color="#ffb20f"></u-icon>
        </div>
        <div class="font-30 font-b col-333 pd_b_20" style="text-align: center">请确认是否已完成三项测评？</div>
        <div class="font-26 col-666 pd_b_45 yh_bd_bottom" style="text-align: center">点击确认后,{{title == '顾问' ? '测试顾问' : '咨询师'}}会尽快为您定制在线报告</div>
      </view>
    </u-modal>
  </div>
</template>

<script>
  import {request} from "../../util/api";
  import {TOAST} from "../../util/util";
  import {THEME} from "../mixins/config";

  export default {
    data() {
      return {
        list: {},
        advisorLabel: [],
        title: '顾问',
        popupShow: false,
        customStyle: {
          background: THEME.btn_active_bg_color,
          padding: '0 30rpx'
        },
        customStyle1: {
          background: '#fff',
          padding: '0 30rpx',
          color: '#101010',
          border: '1px solid #BBBBBB',
          marginTop: '5px'
        },
      }
    },
    onLoad(option) {
      if (option.title == 1) {
        this.title = '顾问';
        uni.setNavigationBarTitle({
          title: '测评顾问'
        });
      } else{
        this.title = '咨询师';
        uni.setNavigationBarTitle({
          title: '咨询师'
        });
      }
    },
    mounted() {
      this.getAdvisorUser()
    },
    methods: {
      getAdvisorUser: function() {
        request({
          url: '/app/userCenter/getAdvisorUser'
        }).then(ret => {
          this.list = ret.data;
          if (ret.data.advisorLabel) {
            this.advisorLabel = ret.data.advisorLabel.split(',');
          }
        })
      },

      copy (txt) {
        uni.setClipboardData({
          data: txt,
          success: function () {
            TOAST("复制成功")
          }
        });
      },

      call(num) {
        uni.makePhoneCall({
          phoneNumber: num
        })
      },
      onClickPopupHide: function() {
        this.popupShow = false;
      },
      onClickConfirm: function() {
        request({
          url: '/wx/addReport',
          method: 'post'
        }).then(res => {
          this.popupShow = false
          TOAST("申请成功，请耐心等待")
        })
        /*request({
          url: '/app/userCenter/submitConsult',
          method: 'post'
        }).then(res => {
          this.popupShow = false
          TOAST(this.title + "已收到消息，感谢您的反馈")
        })*/
      }
    }
  }
</script>

<style lang="scss">
  #consultantId  {
    background: #f7f7f7;
    min-height: 100%;
    .head-portrait {
      width: 163upx;
      height: 163upx;
      border-radius: 50%;
      margin: 0 auto;
    }

    .head-portrait img {
      width: 100%;
      height: 100%;
      border-radius: 50%;
    }

    .btn-style {
      width: 120upx;
      border-radius: 60upx;
      height: 50upx;
      line-height: 50upx;
      border: 1px solid #2A6AAA;
      margin-right: 40upx;
      color: #2A6AAA
    }
    .btn-container {
      /*position: fixed;
      bottom: 0;
      left: 0;*/
      width: 100%;
      padding-left: 30upx;
      padding-right: 30upx;
      /*box-shadow: 1px 8px 16px 0px rgba(0, 0, 0, 0.47);*/
    }
  }
</style>
